package Operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class AddOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("添加图书:");
        Scanner input = new Scanner(System.in);
        System.out.println("请输入图书的名字：");
        String name = input.nextLine();
        System.out.println("请输入图书的作者：");
        String author = input.nextLine();
        System.out.println("请输入图书的价格：");
        int price = input.nextInt();
        input.nextLine();
        System.out.println("请输入图书的类型：");
        String type = input.nextLine();
        Book book = new Book(name, author, price, type);
        bookList.setBook(bookList.getUsedSize(),book);
        bookList.setUsedSize(bookList.getUsedSize() + 1);
        System.out.println("添加图书完成！");
    }
}
